package com.hns.can.energy.service;

import com.hns.can.common.aop.orgTree.LeftOrgAnnotation;
import com.hns.can.common.constants.GlobalConst;
import com.hns.can.common.formula.FillCodeDscValue;
import com.hns.can.common.formula.FillParamsVo;
import com.hns.can.energy.vo.MileageContrastVo;
import com.hns.can.energy.vo.ParamVo;
import com.hns.can.master.entity.CommEnerConsStatInfoEntity;
import com.hns.frame.mybatis.Pagination;
import com.hns.frame.service.CommonService;
import com.hns.tool.pub.PubUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 二汽里程对比数据service
 * @author:Fisher
 * @email:zhuangcaijin@126.com
 * @version Revision 2.0.0
 */
@Service
public class MileContrastService extends CommonService {
    
    @Autowired
    private FillCodeDscValue codeDscValue;

    /**
     *  查询
     * @param conditionVo
     * @return
     * @throws Exception
     */
    @LeftOrgAnnotation()
    @Transactional
    public Pagination searchMileContrast(ParamVo paramVo) throws Exception {
        Pagination page = this.myBatisPage("mileContrast.searchMileContrastCnt", "mileContrast.searchMileContrastData", paramVo,MileageContrastVo.class);
        Map<String,String> map = new HashMap<String,String>();
        map.put("lineName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo fileVo1 = new FillParamsVo("lineId", map);
        codeDscValue.fillInfoValue(page.getData(),new String[] {GlobalConst.CACHE_KEY_BASE_LINE_INFO}, fileVo1);
        return page;
    }

    /**
     * 导出
     * @param conditionVo
     * @return
     * @throws Exception
     */
    @LeftOrgAnnotation()
    @Transactional
    public List<ParamVo> exportMileContrast(ParamVo vo) throws Exception {
        List list = PubUtil.convertListMapToObject(sqlMapDao.selectList("mileContrast.searchMileContrastData", vo), MileageContrastVo.class);
        Map<String,String> map = new HashMap<String,String>();
        map.put("lineName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo fileVo1 = new FillParamsVo("lineId", map);
        codeDscValue.fillInfoValue(list,new String[] {GlobalConst.CACHE_KEY_BASE_LINE_INFO}, fileVo1);
        return list;
    }
}
